class Solution {
    //动态规划
    public int minCostClimbingStairs(int[] cost) {
        int len = cost.length;
        int[] a = new int[len + 1];
        a[0] = a[1] = 0;
        for (int i = 2; i <= len; i++) {
            a[i] = Math.min(a[i - 1] + cost[i - 1], a[i - 2] + cost[i - 2]);
        }
        return a[len];
    }
}